<template>
  <div class="collectrent content-bg">
    <el-table :data="tableData"
              border
              :fit="true"
              style="width: 100%">
      <el-table-column label="房屋id"
                       prop="id">
      </el-table-column>
      <el-table-column label="地址"
                       prop="address">
      </el-table-column>
      <el-table-column label="报障日期"
                       prop="date">
      </el-table-column>
      <el-table-column label="租赁人"
                       prop="name">
      </el-table-column>
      <el-table-column label="报障内容"
                       prop="detail">
      </el-table-column>
      <el-table-column label="状态"
                       prop="status">
      </el-table-column>
    </el-table>
    <div class="pagination-box">
      <el-pagination
        @current-change="handleCurrentChange"
        :current-page="pagination.currentPage"
        :page-size="pagination.pageSize"
        layout="total, prev, pager, next"
        :total="pagination.total">
      </el-pagination>
    </div>
  </div>
</template>
<script lang="js">
import axios from "axios";

export default {
  name: 'processedobstruct',
  data(){
    return {
      tableData: [],
        name: '',
        date: '',
        role:'',
      pagination: {//分页相关模型数据
        currentPage: 1,//当前页码
        pageSize: 10,//每页显示的记录数
        total: 0,//总记录数
        type:"",
        name:"",
        description:"",
      }
    }
  },
  created(){
    this.$store.state.userInfo.role;
    this.getAll();
  },
  methods: {
    getAll: function (){
      axios.get("/wrong/"+this.pagination.currentPage+"/0").then((res)=>{
        if (res.data.code === 1){
          this.tableData = res.data.data.records
          this.pagination.currentPage = res.data.data.current
          this.pagination.total = res.data.data.total
          this.pagination.pageSize = res.data.data.size
        }
      })
    },
      handleDelete(index, row) {
          this.$confirm('确定要删除吗?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'error'
        }).then(() => {
          // 访问接口
          this.$message({
            type: 'success',
            message: '删除成功!'
          });
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '取消成功'
          });
        });
      },
      search(){
        // 访问接口
      },
    //切换页码
    handleCurrentChange(currentPage) {
      this.pagination.currentPage = currentPage;
      this.getAll();
    },
    }
}
</script>
<style lang="scss" scoped>
.processed-obstruct-head {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
  h4 {
    min-width: 100px;
    font-weight: 400;
    font-size: 16px;
  }
  >div {
    display: flex;
    align-items: center;
    margin-right: 20px;
  }
}
</style>
